//
//  TravelTactic_AreaTableViewCell.m
//  Test
//
//  Created by Rain on 15/11/16.
//  Copyright © 2015年 Rain. All rights reserved.
//

#import "TravelTactic_AreaTableViewCell.h"
#import "TravelTactic_AreaModel.h"
#import <UIImageView+WebCache.h>
#import <SDWebImageManager.h>

@interface TravelTactic_AreaTableViewCell ()

@property (nonatomic, retain) UIView *view;

@end

@implementation TravelTactic_AreaTableViewCell

- (void)dealloc {
    [_name_en release];
    [_name_zh_cn release];
    [_image_url release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.view = [[UIView alloc] init];
        self.view.layer.cornerRadius = 5 * SWIDTH;
        self.view.layer.masksToBounds = YES;
        [self.contentView addSubview:self.view];
        [self.view release];
        
        self.image_url = [[UIImageView alloc] init];
        self.image_url.layer.cornerRadius = 10 * SWIDTH;
        self.image_url.layer.masksToBounds = YES;
        [self.view addSubview:self.image_url];
        [self.image_url release];
        
        self.name_zh_cn = [[UILabel alloc] init];
        self.name_zh_cn.font = [UIFont systemFontOfSize:20];
        self.name_zh_cn.shadowColor = [UIColor grayColor];
        self.name_zh_cn.textColor = [UIColor whiteColor];
        [self.image_url addSubview:self.name_zh_cn];
        [self.name_zh_cn release];
        
        self.name_en = [[UILabel alloc] init];
        self.name_en.font = [UIFont systemFontOfSize:16];
        self.name_en.shadowColor = [UIColor grayColor];
        self.name_en.textColor = [UIColor whiteColor];
        [self.image_url addSubview:self.name_en];
        [self.name_en release];
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.view.frame = CGRectMake(5 * SWIDTH, 5 * SWIDTH, self.frame.size.width - 10 * SWIDTH, self.frame.size.height - 10 * SWIDTH);
    self.image_url.frame = CGRectMake(0 * SWIDTH, 0 * SWIDTH, self.view.frame.size.width - 0 * SWIDTH, self.view.frame.size.height - 0 * SWIDTH);
    self.name_zh_cn.frame = CGRectMake(SWIDTH * 10, 10 * SWIDTH, 150 * SWIDTH, 30 * SWIDTH);
    self.name_en.frame = CGRectMake(10 * SWIDTH, 40 * SWIDTH, 150 * SWIDTH, 25 * SWIDTH);
    
}

- (void)setTravelTactic_AreaModel:(TravelTactic_AreaModel *)travelTactic_AreaModel {
    
    if (_travelTactic_AreaModel != travelTactic_AreaModel) {
        [_travelTactic_AreaModel release];
        _travelTactic_AreaModel = [travelTactic_AreaModel retain];
    }
    [self.image_url sd_setImageWithURL:[NSURL URLWithString:_travelTactic_AreaModel.image_url] placeholderImage:[UIImage imageNamed:@"background"]];
    self.name_zh_cn.text = _travelTactic_AreaModel.name_zh_cn;
    self.name_en.text = _travelTactic_AreaModel.name_en;
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
